package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@RestController
@RequestMapping("/common")
public class CommonController {
 @Autowired
 private CommonService commonService;
 @PostMapping("/upload")
 public R<String> upLoad(MultipartFile file) throws IOException {
 String r = commonService.upLoad(file);
  return R.success(r);
 }
 @GetMapping("download")
 public void downLoad(String name, HttpServletResponse response) {
  commonService.download(name,response);
 }
}
